<?php

namespace account;

use bank\BankUtils;
include_once 'Account.php';

class Credit extends Account {
	public function __construct($name, $percent, $period, $balance) {
		$this->setName($name);
		$this->setPercent($percent);
		$this->setPeriod($period);
		$this->setBalance($balance);
		$this->setSum(BankUtils::calculateCreditMontlyPayment($this->getBalance(), $this->getPercent(), $this->getPeriod()));
	}
	public function setBalance($balance) {
		if (is_string ( $balance )) {
			throw new Exception ( 'Credit balance can not be string.' );
		}
		if (! is_numeric ( $balance )) {
			throw new Exception ( 'Credit balance must be numeric' );
		}
		$this->balance = $balance;
	}
	public function getBalance() {
		return $this->balance;
	}
}